package com.letou.ls.uitl;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;

import com.letou.ls.mode.Col;
import com.letou.ls.mode.TableTitle;

import android.content.Context;
import android.text.Layout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.widget.EditText;
import android.widget.TextView;

public class TableUtil {
	// private static final String TAG = "TableUtil";
	private static int number = 0;
	public static OnFocusChangeListener focChange = new OnFocusChangeListener() {

		@Override
		public void onFocusChange(View v, boolean hasFocus) {
			EditText _v = (EditText) v;
			if (!hasFocus) {// 失去焦点
				_v.setHint(v.getTag().toString());
			} else {
				String hint = _v.getHint().toString();
				_v.setTag(hint);
				_v.setHint("");
			}

		}
	};

	public static String changEncoding(String str) {

		String result = null;
		try {
			result = URLEncoder.encode(str, "gb2312");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} // 匹配整个字符�?
		return result;
	}

	/**
	 * 获得两个ArrayList<String> 第一个代表col1，第二个代表col2�?
	 * 
	 * @param data
	 * @return
	 */
	public static ArrayList<ArrayList<String>> getData(ArrayList<ArrayList<ArrayList<String>>> data) {
		ArrayList<ArrayList<String>> list = null;
		ArrayList<String> xList, yList;
		if (data != null) {
			int size = data.size();
			xList = new ArrayList<String>();
			yList = new ArrayList<String>();
			for (int index = 0; index < size; index++) {
				ArrayList<ArrayList<String>> dataitem = data.get(index);
				for (int i = 0; i < 2; i++) {
					if (i == 0) {
						xList.add(dataitem.get(i).get(0));
					} else {
						yList.add(dataitem.get(i).get(0));
					}
					// Logger.v(TAG, " " + i + " " + dataitem.get(i).get(0));
				}
			}
			list = new ArrayList<ArrayList<String>>();
			list.add(xList);
			list.add(yList);
		}
		return list;
	}

	/**
	 * 三层list 转化为两层list�?
	 * 
	 * @param data
	 * @return
	 */
	public static ArrayList<ArrayList<String>> getColList(ArrayList<ArrayList<ArrayList<String>>> data) {
		if (data == null || data.isEmpty()) {
			return null;
		}
		ArrayList<ArrayList<String>> list;
		int size = data.size();
		int listNumber = data.get(0).size();
		list = new ArrayList<ArrayList<String>>();
		for (int index = 0; index < listNumber; index++) {
			list.add(new ArrayList<String>());
		}
		for (int index = 0; index < size; index++) {
			ArrayList<ArrayList<String>> dataitem = data.get(index);
			int ss = dataitem.size();// listNumber
			for (int i = 0; i < ss; i++) {
				if (i < listNumber) {
					list.get(i).add(dataitem.get(i).get(0));
				}
			}
		}

		return list;
	}

	/**
	 * col数据 横向存储转化为纵向存储�?（最里层list �?��保留�?
	 * 
	 * @param data
	 * @return
	 */
	public static ArrayList<ArrayList<ArrayList<String>>> getChangeList(ArrayList<ArrayList<ArrayList<String>>> data) {
		if (data == null || data.isEmpty()) {
			return null;
		}
		ArrayList<ArrayList<ArrayList<String>>> list;
		int size = data.size();
		int listNumber = data.get(0).size();
		list = new ArrayList<ArrayList<ArrayList<String>>>();
		for (int index = 0; index < listNumber; index++) {
			list.add(new ArrayList<ArrayList<String>>());
		}

		for (int index = 0; index < size; index++) {
			List<ArrayList<String>> dataitem = data.get(index);
			int ss = dataitem.size();// listNumber
			for (int i = 0; i < ss; i++) {
				if (i < listNumber) {
					list.get(i).add(dataitem.get(i));
				}
			}
		}

		return list;
	}

	/**
	 * col数据 横向存储转化为纵向存储�?（最里层list �?��保留�?
	 * 
	 * @param data
	 * @return
	 */
	public static ArrayList<ArrayList<ArrayList<String>>> getChangeListA(ArrayList<ArrayList<ArrayList<String>>> data) {
		if (data == null || data.isEmpty()) {
			return null;
		}
		ArrayList<ArrayList<ArrayList<String>>> list;
		int size = data.size();
		int listNumber = data.get(0).size();
		list = new ArrayList<ArrayList<ArrayList<String>>>();
		for (int index = 0; index < listNumber; index++) {
			list.add(new ArrayList<ArrayList<String>>());
		}

		for (int index = 0; index < size; index++) {
			ArrayList<ArrayList<String>> dataitem = data.get(index);
			int ss = dataitem.size();// listNumber
			for (int i = 0; i < ss; i++) {
				if (i < listNumber) {
					list.get(i).add(dataitem.get(i));
				}
			}
		}

		return list;
	}

	/**
	 * col数据 横向存储转化为纵向存储�?
	 * 
	 * @param data
	 * @return
	 */
	public static ArrayList<ArrayList<String>> getChangeListB(ArrayList<ArrayList<String>> data) {
		if (data == null || data.isEmpty()) {
			return null;
		}
		ArrayList<ArrayList<String>> list;
		int size = data.size();
		for (int index = 0; index < size; index++) {
			for (int j = 0; j < size; j++) {
			}
		}

		int listNumber = data.get(0).size();
		list = new ArrayList<ArrayList<String>>();
		for (int index = 0; index < listNumber; index++) {
			list.add(new ArrayList<String>());
		}

		for (int index = 0; index < size; index++) {
			ArrayList<String> dataitem = (ArrayList<String>) data.get(index);
			int ss = dataitem.size();// listNumber
			for (int i = 0; i < ss; i++) {
				if (i < listNumber) {
					list.get(i).add(dataitem.get(i));
				}
			}
		}
		return list;
	}

	/**
	 * 根据number 的�?取得data 中第几列数据�?�?可以单个去col2 的数�?number=1�?
	 * 
	 * @param data
	 * @param number
	 * @return
	 */
	public static ArrayList<String> getColList(ArrayList<ArrayList<ArrayList<String>>> data, int number) {
		if (data == null || data.isEmpty() || number < 0) {
			return null;
		}
		ArrayList<String> list = new ArrayList<String>();
		int size = data.size();
		for (int index = 0; index < size; index++) {
			ArrayList<ArrayList<String>> dataitem = data.get(index);
			if (dataitem.size() > number)
				list.add(dataitem.get(number).get(0));
		}

		return list;
	}

	@SuppressWarnings("unchecked")
	public static void getIsUrl(TableTitle title, ArrayList<ArrayList<ArrayList<String>>> data) {
		Logger.v("ls", "getIsUrl    ... ");
		if (data == null || data.isEmpty()) {
			return;
		}
		// getChangeList

		ArrayList<ArrayList<ArrayList<String>>> newData;
		newData = (ArrayList<ArrayList<ArrayList<String>>>) data.clone();
		newData = getChangeListA(data);
		ArrayList<Boolean> list;
		list = new ArrayList<Boolean>();
		int size = newData.size();
		for (int index = 0; index < size; index++) {
			boolean sign = false;
			// int ss = newData.get(index).size();
			// for (int i = 0; i < ss; i++) {
			// if (newData.get(index).get(i).size() > 1) {
			// sign = true;
			// break;
			// }
			// }
			list.add(sign);
			Logger.v("ls", "sign    " + sign);
		}
		number = 0;
		setIsUrl(title.getDataCol(), list);
	}

	/**
	 * 设置叶子结点宽度。
	 * 
	 * @param col
	 * @param rowWidthList
	 * @param num
	 */
	private static void setIsUrl(Col col, ArrayList<Boolean> isUrlArray) {
		int size = col.getmChildrenSize();
		if (size == 0) {

			col.setIsUrl(isUrlArray.get(number));
			number++;
			// Logger.v(TAG, "number **** " + col.isUrl());
		}
		if (size > 0) {
			for (int index = 0; index < size; index++) {
				setIsUrl(col.getmChildList().get(index), isUrlArray);
			}
		}
	}

	/**
	 * 文字宽度转化为整形。
	 */
	private static void updataData(Col col) {
		int size = col.getmChildrenSize();
		if (size == 0) {

		} else {
			for (int index = 0; index < size; index++) {
				Col currentCol = col.getmChildList().get(index);
				currentCol.setmColName(currentCol.getmColName().replaceAll("\n", ""));
				updataData(currentCol);
			}
		}
	}

	private static String getRealMaxStr(ArrayList<String> list, TextPaint paint) {
		if (list == null || list.isEmpty()) {
			return null;
		}
		int size = list.size();
		int number = 0;
		float widthm;
		float max = 0;
		String text;
		for (int index = 0; index < size; index++) {
			text = list.get(index);
			widthm = Layout.getDesiredWidth(text, 0, text.length(), paint);
			if (index == 0) {
				max = widthm;
				number = index;
			}
			if (widthm > max) {
				max = widthm;
				number = index;
			}
		}
		return list.get(number);
	}

	/**
	 * 计算最大宽度。
	 * 
	 * @param list
	 * @return
	 */
	public static String getMaxStr(ArrayList<String> list) {
		if (list == null || list.isEmpty()) {
			return null;
		}
		String str;
		int size = list.size();
		str = list.get(0);
		int max = str.length();
		int currentlgh;
		String currentstr;
		for (int index = 0; index < size; index++) {
			currentstr = list.get(index);
			currentlgh = currentstr.length();
			if (max < currentlgh) {
				str = currentstr;
				max = currentlgh;
			}
		}
		if (max < 2) {
			str = str + "s";
		}
		return str;
	}

	public static void getTableTitleByWidth(TableTitle title, ArrayList<ArrayList<ArrayList<String>>> data,
			Context context, int screenWidth, float maxSize) {
		if (data == null || data.isEmpty()) {
			return;
		}
		updataData(title.getDataCol());
		// getIsUrl(title, data);
		ArrayList<ArrayList<String>> dataNew = getColList(data);
		ArrayList<String> rowMaxList = new ArrayList<String>();// 列中最大文字长度列表。
		StringBuffer strbuf = new StringBuffer();
		ArrayList<Boolean> isUrlCol = new ArrayList<Boolean>();
		float textSize;// 字体大小。
		TextView textView = new TextView(context);
		textSize = maxSize;
		textView.setTextSize(textSize);
		TextPaint paint = textView.getPaint();

		getChildIsUrl(title.getDataCol(), isUrlCol);
		int size = dataNew.size();
		String str;
		String text = "ss";
		// Logger.v("lss", " size " + size);
		float widthm = Layout.getDesiredWidth(text, 0, text.length(), paint);
		for (int index = 0; index < size; index++) {
			if (index == 0) {// 第一列 文字的
				str = getRealMaxStr(dataNew.get(index), paint);
			} else {// 数据列
				str = getMaxStr(dataNew.get(index));
			}
			float strWid = Layout.getDesiredWidth(str, 0, str.length(), paint);
			if (strWid < widthm) {
				str = text;
			}
			if (isUrlCol.get(index)) {
				Logger.v("ls", "ss " + str);
				str = str + "s";
			}
			strbuf.append(str);
			rowMaxList.add(str);
		}
		str = strbuf.toString();
		if (TextUtils.isEmpty(str)) {
			return;
		}
		float paddingWidth = 3 * rowMaxList.size();
		float strWidth = Layout.getDesiredWidth(str, 0, str.length(), paint);
		if (screenWidth - paddingWidth > strWidth) {

		} else {
			textSize = getTextSize(textSize, str, (screenWidth - paddingWidth), textView);
		}

		title.getDataCol().setmDataWidth(screenWidth);
		changeSize(title, textSize, rowMaxList, screenWidth, maxSize, textView);

		return;
	}

	/**
	 * 根据屏幕宽 计算字号。
	 */
	private static float getTextSize(float textSize, String str, float screenWidth, TextView textView) {
		float strWidth;// 宽度。

		if (TextUtils.isEmpty(str)) {
			return textSize;
		}

		textView.setTextSize(textSize);
		TextPaint paint = textView.getPaint();

		strWidth = Layout.getDesiredWidth(str, 0, str.length(), paint);
		while (strWidth > screenWidth && textSize > 0) {
			textSize--;
			textView.setTextSize(textSize);
			paint = textView.getPaint();
			strWidth = Layout.getDesiredWidth(str, 0, str.length(), paint);
		}
		// int cunt = 0;
		// while (strWidth < screenWidth && textSize > 0 && cunt < 7) {
		// textSize = textSize + 0.1f;
		// Logger.v(TAG, "textSize +++ " + textSize + " " + strWidth);
		// cunt++;
		// textView.setTextSize(textSize);
		// paint = textView.getPaint();
		// strWidth = Layout.getDesiredWidth(str, 0, str.length(), paint);
		// }
		// Logger.v(TAG, "strWidth " + strWidth + " " + screenWidth);
		// if (strWidth > screenWidth) {
		// textSize = textSize - 0.1f;
		// }

		return textSize;
	}

	private static TableTitle changeSize(TableTitle title, float textSize, ArrayList<String> rowMaxList,
			int screenWidth, float maxSize, TextView textView) {
		ArrayList<Float> dataWidth = new ArrayList<Float>();
		TextPaint paint = textView.getPaint();

		int size = rowMaxList.size();
		for (int index = 0; index < size; index++) {
			String text = rowMaxList.get(index);
			float strWidth = Layout.getDesiredWidth(text, 0, text.length(), paint);
			dataWidth.add(strWidth);
		}

		float getAllWidth = getWidthAll(dataWidth);
		number = 0;
		textView.setTextSize(textSize);
		getAllWidth = (screenWidth - getAllWidth - size) / size;
		paint = textView.getPaint();
		title.setDataTextSize(textSize);
		setChildWidthAndHeight(title.getDataCol(), dataWidth, getAllWidth, textSize, paint);
		setfatherWidth(title.getDataCol());
		setfatherHeight(title.getDataCol(), textSize, paint);
		updateHeaderRow2(title);
		setIntforfloat(title.getDataCol(), title);

		return title;
	}

	private static void updateHeaderRow2(TableTitle title) {
		Col col = title.getDataCol();
		int maxNumber = title.getmMaxNumber();
		clearChildRow(col);
		int maxRaw = 0;
		for (int index = maxNumber; index > 0; index--) {
			maxRaw = maxHeightAll(col, index);
			updataHeight(title.getDataCol(), index, maxRaw);
			updataChildRow(title.getDataCol(), index - 1);
		}

	}

	/**
	 * 设置同一层最高的高度。
	 * 
	 * @param col
	 * @param row
	 * @return
	 */
	private static void updataHeight(Col col, int row, int height) {
		int size = col.getmChildrenSize();
		for (int index = 0; index < size; index++) {
			Col child = col.getmChildList().get(index);
			if (child.getmNumber() == row) {
				int hgt = height - child.getmChildMaxRow();
				child.setmRowspan(hgt);
			} else if (child.getmChildrenSize() != 0) {
				updataHeight(child, row, height);
			}
		}
	}

	/**
	 * 查找同一层最高的高度。
	 * 
	 */
	private static int maxHeightAll(Col col, int row) {
		int size = col.getmChildrenSize();
		int max = 0;

		for (int index = 0; index < size; index++) {
			Col child = col.getmChildList().get(index);

			if (child.getmNumber() == row && max < (child.getmRowspan() + child.getmChildMaxRow())) {
				max = child.getmRowspan() + child.getmChildMaxRow();
			} else if (child.getmChildrenSize() != 0) {
				int temp = maxHeightAll(child, row);
				if (max < temp) {
					max = temp;
				}
			}
		}
		return max;
	}

	/**
	 * 更新节点中子最大孩子高度。
	 * 
	 * @param col
	 * @param row
	 * @return
	 */
	private static void updataChildRow(Col col, int row) {
		int size = col.getmChildrenSize();
		for (int index = 0; index < size; index++) {
			Col child = col.getmChildList().get(index);
			if (child.getmNumber() == row) {
				int number;
				if (child.getmChildrenSize() > 0) {
					number = child.getmChildList().get(0).getmRowspan();
				} else {
					number = 0;
				}
				child.setmChildMaxRow(number);
			} else if (child.getmChildrenSize() != 0) {
				updataChildRow(child, row);
			}
		}
	}

	private static void clearChildRow(Col col) {
		int size = col.getmChildrenSize();
		for (int index = 0; index < size; index++) {
			Col newCol = col.getmChildList().get(index);
			newCol.setmChildMaxRow(0);
			clearChildRow(newCol);
		}
	}

	/**
	 * 文字宽度转化为整形。
	 */
	private static void setIntforfloat(Col col, TableTitle title) {
		int size = col.getmChildrenSize();
		int widthFatcher = (int) col.getmDataWidth();
		if (size == 0) {
			if (col.getmDataWidth() > 0) {
				title.addWidthList(col.getmDataWidth());
			}
		} else {
			for (int index = 0; index < size; index++) {
				Col currentCol = col.getmChildList().get(index);
				if (index < size - 1) {
					int curWidth = (int) currentCol.getmDataWidth();
					currentCol.setmDataWidth(curWidth);
					widthFatcher -= curWidth;

				} else {
					currentCol.setmDataWidth(widthFatcher);
				}
				setIntforfloat(currentCol, title);
			}
		}
	}

	/**
	 * 设置父结点高度。
	 * 
	 * @param col
	 * @param rowWidthList
	 * @param num
	 */
	private static void setfatherHeight(Col col, float textSize, TextPaint paint) {
		int size = col.getmChildrenSize();
		if (size != 0 && !TextUtils.isEmpty(col.getmColName())) {
			String text = col.getmColName();

			float widthm = Layout.getDesiredWidth(text, 0, text.length(), paint);

			// float[] widths = new float[text.length()];
			int count = text.length();
			// Logger.v("lsss", "setfatherHeight " + pFont.getTextSize());
			int num = 1;
			float width = col.getmDataWidth() - 2;
			float eathWidth = 0;
			String space = "\n";
			StringBuffer str = new StringBuffer(text);

			for (int index = 0; index < count; index++) {
				widthm = Layout.getDesiredWidth(text, index, index + 1, paint);
				eathWidth += widthm;
				if (eathWidth >= width) {
					num++;
					eathWidth = widthm;// 装不下 换行

					int number = index + num - 2;
					if (number < str.length()) {
						str.insert(number, space);
					}
				}
			}
			col.setmTextSize(textSize);
			col.setmRowspan(num);
			col.setmColName(str.toString());
		}
		for (int index = 0; index < size; index++) {
			setfatherHeight(col.getmChildList().get(index), textSize, paint);
		}
	}

	/**
	 * 获得宽度总和。
	 * 
	 * @param realwidth
	 * @return
	 */
	public static float getWidthAll(ArrayList<Float> realwidth) {
		int size = realwidth.size();
		float mun = 0;
		for (int index = 0; index < size; index++) {
			mun += realwidth.get(index);
		}
		return mun;
	}

	/**
	 * 增加 叶子节点宽。
	 * 
	 * @param col
	 * @param rowWidthList
	 * @param num
	 */
	private static void getChildIsUrl(Col col, ArrayList<Boolean> isUrlCol) {
		int size = col.getmChildrenSize();
		if (size == 0) {
			isUrlCol.add(col.isUrl());
		}
		if (size > 0) {
			for (int index = 0; index < size; index++) {
				getChildIsUrl(col.getmChildList().get(index), isUrlCol);
			}
		}
	}

	/**
	 * 设置叶子结点宽度和高度。
	 * 
	 * @param col
	 * @param rowWidthList
	 * @param num
	 */
	private static void setChildWidthAndHeight(Col col, ArrayList<Float> widthList, float moreWidth, float textSize,
			TextPaint paint) {
		int size = col.getmChildrenSize();
		if (size == 0) {
			String text = col.getmColName();

			float widthm = Layout.getDesiredWidth(text, 0, text.length(), paint);

			// float[] widths = new float[text.length()];
			// int count = pFont.getTextWidths(text, 0, text.length(), widths);
			int num = 1;
			// Logger.v("lss", "setChildWidthAndHeight " + number + " " +
			// widthList.size());
			// int maxSize = widthList.size();
			// if (number < maxSize) {
			col.setmDataWidth(widthList.get(number) + moreWidth);
			// }
			float width = col.getmDataWidth() - 2;
			float eathWidth = 0;
			String space = "\n";
			StringBuffer str = new StringBuffer(text);
			int count = text.length();
			// 算高度
			for (int index = 0; index < count; index++) {
				widthm = Layout.getDesiredWidth(text, index, index + 1, paint);
				eathWidth += widthm;
				if (eathWidth >= width) {
					num++;
					eathWidth = widthm;// 装不下 换行
					int number = index + num - 2;
					if (number < str.length()) {
						str.insert(number, space);
					}
				}
			}

			// col.setmRowspan(num);
			col.setmRowspan(1);
			col.setmTextSize(textSize);
			col.setmColName(str.toString());
			number++;
		}
		if (size > 0) {
			for (int index = 0; index < size; index++) {
				setChildWidthAndHeight(col.getmChildList().get(index), widthList, moreWidth, textSize, paint);
			}
		}
	}

	/**
	 * 设置父结点宽度。
	 * 
	 * @param col
	 * @param rowWidthList
	 * @param num
	 */
	private static float setfatherWidth(Col col) {
		int size = col.getmChildrenSize();
		float width = 0;
		if (size == 0) {
			// Logger.v("lss", "width " + col.getmDataWidth() + " " +
			// col.getmNumber());
			return col.getmDataWidth();
		} else {
			for (int index = 0; index < size; index++) {
				width += setfatherWidth(col.getmChildList().get(index));
			}
			col.setmDataWidth(width);
		}
		// Logger.v("lss", "width " + width + " " + col.getmNumber());
		return width;
	}

	public static TableTitle changeTitle(ArrayList<ArrayList<ArrayList<String>>> data) {
		TableTitle title = new TableTitle();

		int size = data.size();

		if (title.getCurrentCol() == null) {
			title.addFirstCol();
		}
		if (title.getCurrentCol().getCurrentChild() == null) {
			title.addCurrentColChild(new Col());
		}
		Col firstCol = title.getDataCol();
		for (int index = 0; index < size; index++) {
			ArrayList<ArrayList<String>> item = data.get(index);
			int colSize = item.size();

			title.goToAfter();// 进入 就先向下进入一层
			for (int j = 0; j < colSize; j++) {

				String text1;
				String text2 = null;
				text1 = item.get(j).get(0);
				String stye = null;
				if (item.get(j).size() > 1) {
					stye = item.get(j).get(1);
				}
				if (j < colSize - 1) {
					text2 = item.get(j + 1).get(0);
				}
				if (text1.equals(text2)) {

				} else {
					Col col = new Col();
					col.setmColName(text1);
					col.setmNumber(firstCol.getmNumber() + 1);
					col.setStye(stye);

					Logger.v("ls", "text1  " + text1 + "  " + col.getmNumber());
					if (index == 0) {
						Logger.v("ls", "add  " + text1);
						firstCol.addChildren(col);
					} else {
						String uptext = data.get(index - 1).get(j).get(0);

						if (uptext.equals(text1)) {

						} else {

							ArrayList<String> array = new ArrayList<String>();
							for (int k = 0; k < index; k++) {
								Logger.v("ls", "changeTitle  " + data.get(k).get(j).get(0));
								array.add(data.get(k).get(j).get(0));
							}
							addNodeInTree(text1, stye, firstCol, array);
						}
					}
				}

			}
		}

		return title;

	}

	private static void addNodeInTree(String text, String stye, Col col, ArrayList<String> array) {
		if (array == null || array.size() <= 0) {
			return;
		}

		int size = col.getmChildrenSize();
		Col node = null;
		Logger.v("ls", "addNodeInTree  size " + size);
		for (int index = 0; index < size; index++) {

			node = col.getmChildList().get(index);
			Logger.v("ls", "addNodeInTree  " + node.getmColName() + "  " + array.get(0));
			if (node.getmColName().equals(array.get(0))) {
				break;
			} else {
				node = null;
			}
		}
		if (node != null) {
			addNode(text, stye, node, array);
		}
	}

	private static void addNode(String text, String stye, Col col, ArrayList<String> array) {

		if (array.size() == 1) {

			Col childNode = new Col();
			childNode.setmColName(text);
			childNode.setStye(stye);

			childNode.setmNumber(col.getmNumber() + 1);
			col.addChildren(childNode);

		} else {
			array.remove(0);

			int size;
			size = col.getmChildrenSize();

			for (int index = 0; index < size; index++) {
				Col item = col.getmChildList().get(index);
				String sign = array.get(0);
				if (sign.equals(item.getmColName())) {
					addNode(text, stye, item, array);
					break;
				}
			}

		}

	}
}
